// 使用偏移量计算元素位置的二维数组

#include <iostream>
using namespace std;

int main() {
    int rowsize;
    int colsize;
    cout << "输入二维数组的行和列: ";
    cin >> rowsize >> colsize;

    int* a = new int[rowsize * colsize];
    for (int i = 0, v = 0; i < rowsize; i++) {
        for (int j = 0; j < colsize; j++, v++) {
            int index = i*colsize + j;
            a[index] = v;
            cout << i << "行, " << j << "列 = " << a[index] << "\n";
        }
    }
    cout << "完毕\n";
    delete []a;
}